/*
 * CacheAspect.aj
 * 
 *  author: Daniel Rudigier
 *    date: 07.12.2008
 * 
 * 
 */
package at.momberban2.me.aspects;

import java.io.IOException;

import javax.microedition.lcdui.Image;

import de.enough.polish.util.HashMap;

/**
 * @author Daniel Rudigier
 *
 */
public aspect CacheAspect {
    
    private HashMap images = new HashMap();
    
//    private HashMap maps = new HashMap();
    
//    pointcut mapCreate(): call (at.momberban2.me.gamecontext.M2Map.new());
    
    pointcut imageCreate(): call (Image javax.microedition.lcdui.Image.createImage(String));
    
    Image around(): imageCreate() {
        String location = (String) thisJoinPoint.getArgs()[0];
        Image ret = (Image) this.images.get(location);
        
        if (ret == null) {
            System.out.println("not cached yet");
            ret = proceed();
        } 
        
        return ret;
    }

}
